<template>
  <ContentWrap>
    <!-- 搜索工作栏 -->
    <el-form
      class="-mb-15px"
      :model="form"
      ref="queryFormRef"
      label-width="140px"
    >
    <div style="border-left: 4px solid #105cfb;padding-left: 10px;">运营设置</div>
    <el-form-item label="门店切换" style="margin-top: 10px;">
      <el-radio-group v-model="form.switchs">
        <el-radio
            v-for="dict in getIntDictOptions(DICT_TYPE.STORE_SWITCH)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
      </el-radio-group>
      <div style="color: #b2b2b2;margin-left: 20px;display: block;font-size: 12px;">禁止切换门店，会锁定距离用户最近的门店，定位失败进入默认距离最近的门店</div>
    </el-form-item>
    <el-form-item label="门店确认弹窗">
      <el-radio-group v-model="form.confirmWindows">
        <el-radio
            v-for="dict in getIntDictOptions(DICT_TYPE.STORE_CONFIRM_WINDOWS)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
      </el-radio-group>
      <div style="color: #b2b2b2;margin-left: 20px;display: block;font-size: 12px;">开启后，每次进入门店时弹窗提示选择门店</div>
    </el-form-item>
    <!-- <div style="border-left: 4px solid #105cfb;padding-left: 10px;">核算设置</div>
    <el-form-item label="门店收益单独核算" style="margin-top: 10px;">
      <el-radio-group v-model="form.separateAccountingIncome">
        <el-radio
            v-for="dict in getIntDictOptions(DICT_TYPE.STORE_SEPARATE_ACCOUNTING_INCOME)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
      </el-radio-group>
      <div style="color: #b2b2b2;margin-left: 20px;display: block;font-size: 12px;">开启后，每个门店的收益会进入门店的收款方式  </div>
    </el-form-item> -->
    <el-form-item>
      
        <el-button @click="submitForm" type="primary" >保 存</el-button>
      
    </el-form-item>
    
    </el-form>
  </ContentWrap>


</template>

<script setup lang="ts">

import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import { SystemApi, SystemVO } from '@/api/mall/store/system'

/** 门店设置 列表 */
defineOptions({ name: 'System' })

const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化

const form = ref({
  id: undefined,
  switchs: undefined,
  confirmWindows: undefined,
  separateAccountingIncome: undefined
})
const queryFormRef = ref() // 搜索的表单
const queryParams = reactive({
  pageNo: 1,
  pageSize: 2
})
const formLoading = ref(false)

//查询租户门店设置
const getSystem = async () => {
  form.value = await SystemApi.getSystemPage(queryParams)
  form.value =form.value.list[0] 
  // console.log(form.value.list[0])
}

const submitForm = async () => {
  const data = form.value as unknown as SystemVO;
  await SystemApi.updateSystem(data);
  message.success("保存成功")
}

/** 初始化 **/
onMounted(() => {
  getSystem()
})


</script>